package com.example.wlt.personnel_manegement_system.User.Task;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;

import com.example.wlt.personnel_manegement_system.Adapter.TaskAdapter;
import com.example.wlt.personnel_manegement_system.Item.Item_task;
import com.example.wlt.personnel_manegement_system.R;
import com.example.wlt.personnel_manegement_system.User.My.Mycenter;
import com.example.wlt.personnel_manegement_system.User.Org.Organization;
import com.example.wlt.personnel_manegement_system.User.Org.search;
import com.example.wlt.personnel_manegement_system.User.Person.Person;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by WLT on 2016/4/18.
 */
public class Task extends Activity implements AdapterView.OnItemClickListener{
    private ImageButton ibtn_org;
    private ImageButton ibtn_person;
    private ImageButton ibtn_mycenter;
    private ListView lv_item;
    private Button btn_TaskBack;//返回按钮
    private ImageButton ibtn_search;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.u_task);
        ibtn_org=(ImageButton)findViewById(R.id.ibtn_org);
        ibtn_person=(ImageButton)findViewById(R.id.ibtn_person);
        ibtn_mycenter=(ImageButton)findViewById(R.id.ibtn_mycenter);
        btn_TaskBack = (Button) findViewById(R.id.btn_org_headleft);
        ibtn_search=(ImageButton)findViewById(R.id.ibtn_org_search);
        lv_item=(ListView)findViewById(R.id.lv_taskhistory_item);
        //设置item监听器
        lv_item.setOnItemClickListener(this);
        //创建数据源
        List<Item_task> Item=new ArrayList<>();
        for(int i=0;i<20;i++){
            Item.add(new Item_task(
                    "人事管理f系统"
            ));
        }
        //加载适配器
        lv_item.setAdapter(new TaskAdapter(this, this, Item));
        //进入搜索页面
        ibtn_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent Intent=new Intent(Task.this, search.class);
                startActivity(Intent);
            }
        });
        //返回app首页即部门页面
        btn_TaskBack.setOnClickListener(new View.OnClickListener() {//点击按钮返回主页面，即部门页面
            @Override
            public void onClick(View view) {
                Intent Intent = new Intent(Task.this,Organization.class);
                startActivity(Intent);
                finish();
            }

        });
        //进入个人页面
        ibtn_mycenter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent Intent=new Intent(Task.this,Mycenter.class);
                startActivity(Intent);
                finish();
            }
        });
        //进入部门页面
        ibtn_org.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent Intent = new Intent(Task.this,Organization.class);
                startActivity(Intent);
                finish();
            }
        });
        //进入成员页面
        ibtn_person.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent Intent = new Intent(Task.this,Person.class);
                startActivity(Intent);
                finish();
            }
        });
    }
    //item监听事件
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        Intent memberstatusIntent = new Intent(Task.this,Checkhistory.class);
        startActivity(memberstatusIntent);
    }
}